import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.implicitly_wait(10)
driver.maximize_window()
#固定资产台账增删改查
def login():
    #打开地址
    driver.get('http://10.10.10.120:30202')
    #输入用户名密码
    driver.find_element(By.ID,'username').send_keys('administrator')
    driver.find_element(By.ID,'password').send_keys('Gdjt@2021')
    driver.find_element(By.XPATH,'//button').click()
    time.sleep(5)
    driver.find_element(By.XPATH,'//*[text()="资产信息管理"]').click()
    driver.find_element(By.XPATH,'//*[text()="固定资产台账"]').click()
    #新建借用单据
    driver.find_element(By.XPATH, '//button[@class="ant-btn   ant-btn-primary"]').click()
    driver.find_element(By.XPATH, '//input[@class="ant-radio-input"]').click()
    driver.find_element(By.XPATH, '//input[@class="ant-radio-input"]').click()
    driver.find_element(By.XPATH, '//*[text()="确 定"]/..').click()

    #输入单据名称
    driver.find_element(By.XPATH, '(//*[@id="sname"])[2]').send_keys("借用单据")
    #保存单据
    driver.find_element(By.XPATH, '//*[text()="保 存"]/..').click()
    time.sleep(3)
    num = driver.find_element(By.XPATH, '//div[text()="单据编号"]/following-sibling::div[1]').text
    driver.find_element(By.XPATH, '//button[@aria-label="Close"]').click()
    driver.find_element(By.XPATH, '//*[text()="固定资产过程管理"]').click()
    driver.find_element(By.XPATH, '//*[text()="资产变更历史台账"]').click()
    time.sleep(3)
    driver.find_element(By.XPATH, '//input[@type="text"]').send_keys(num)
    time.sleep(3)
    driver.find_element(By.XPATH, '//*[text()="资产信息管理"]').click()
    driver.find_element(By.XPATH, '//*[text()="固定资产台账"]').click()

    #修改单据代码标识
    driver.find_element(By.XPATH, '//*[text()="操作"]/.').click()
    time.sleep(3)
    driver.find_element(By.XPATH, '//*[text()="修改"]/.').click()

    driver.find_element(By.XPATH, '//*[@id="sidentify_code"]').send_keys('长春1号线、2号线改修项目')
    driver.find_element(By.XPATH, '//*[text()="保 存"]/..').click()
    driver.find_element(By.XPATH,'//button[@aria-label="Close"]').click()

    time.sleep(2)
    #删除
    driver.find_element(By.XPATH, '//*[text()="操作"]/.').click()
    time.sleep(3)
    driver.find_element(By.XPATH, '//*[text()="删除"]/.').click()
    driver.find_element(By.XPATH, '//*[text()="确 定"]/.').click()



if __name__ == '__main__':
    login()
    time.sleep(5)